<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="page" %>
<%@taglib prefix="sp" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
    <title>登录</title>
</head>
<body>
<span>
    <span class="error-msg">${requestScope.error}</span>
    <span class="success-msg">${requestScope.success}</span>
</span>
<div style="width: 300px;margin-left: auto;margin-right: auto;">
    <h2><sp:message code="web.admin.login.title"/></h2>

    <form id="login_form" method="post"
          action="${pageContext.request.contextPath}/admin/user/validateLogin.html">
        <div>
            <div>
                            <span class="block input-icon input-icon-right">
															<input type="text" class="form-control"
                                                                   placeholder="<sp:message code="web.username" /> "
                                                                   autofocus="true"
                                                                   name="userName"
                                                                   datatype="userName"
                                                                   nullmsg="<sp:message code="validate.username.null.error" /> "
                                                                   errormsg="<sp:message code="validate.username.reg.error" /> ">
															<i class="icon-user"></i>
														</span>
            </div>
            <p class="form_prompt"><sp:message code="web.username.prompt"/></p>
        </div>
        <div>
            <div>
                                   <span class="block input-icon input-icon-right">
															<input type="password" class="form-control"
                                                                   placeholder="<sp:message code="web.password" /> "
                                                                   name="password" datatype="password"
                                                                   nullmsg="<sp:message code="validate.password.null.error" />"
                                                                   errormsg="<sp:message code="validate.password.reg.error" /> ">
															<i class="icon-lock"></i>
														</span>
            </div>
            <p class="form_prompt"><sp:message code="web.password.prompt"/></p>
        </div>
        <div class="field">
            <div>
                <span>
                <input class="form-control" name="authcode" type="text" datatype="authcode" placeholder="<sp:message code="web.authcode" />"
                       nullmsg="<sp:message code="validate.authcode.null.error" />"
                       errormsg="<sp:message code="validate.authcode.reg.error" /> "/>
                    </span>
            </div>
            <p class="form_prompt"><sp:message code="web.authcode.prompt"/></p>
        </div>
        <div class="clearfix">
            <label class="inline">
                <img id="forgetpwd_autcode_image" alt="" title="<sp:message code="web.authcode.image.change.title" /> "
                     src="${pageContext.request.contextPath}/codeImg.html" onclick="login.authCodeChange(this)"/>
            </label>

            <a href="${pageContext.request.contextPath}/admin/forgetpwd.html"
               style="cursor: pointer;"><sp:message code="web.login.forgetpwd"/> </a>
            <button type="submit" class="width-35 pull-right btn btn-sm btn-primary">
                <i class="icon-ok align-top"></i>
                <sp:message code="web.login"/>
            </button>
        </div>
    </form>
</div>

<script>
    $('#login_form').Validform({
        btnSubmit: "button[type=submit]",
        showAllError: false,
        postonce: true,
        ajaxPost: false,
        tiptype: function (msg, o, cssctl) {
            if (!o.obj.is("form")) {
                var objtip = o.obj.parent().parent().next(".form_prompt");
                cssctl(objtip, o.type);
                objtip.text(msg);
            }
        },
        beforeSubmit: function (curform) {
            return true;
        }
    });
    $('#login_form input').keydown(function (e) {
        if (e.keyCode == 13) {
            $('#login_form').submit();
        }
    });
    var login = {
        authCodeChange: function (d) {
            $(d).attr("src", "../codeImg.html?d=" + new Date().getTime())
        }
    };
</script>
</body>
</html>
